package com.dana.friend.controller.user;

import com.core.controller.BaseController;
import com.core.domain.Result;
import com.dana.api.domain.vo.UserQuestionResultVO;
import com.dana.friend.domain.user.dto.UserQuestionSubmitDTO;
import com.dana.friend.service.user.IUserQuestionService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/user/question")
public class UserQuestionController extends BaseController {

    @Autowired
    private IUserQuestionService userQuestionService;

    /**
     * 用户提交代码
     */
    @PostMapping("/submit")
    public Result<UserQuestionResultVO> submit(@RequestBody UserQuestionSubmitDTO userQuestionSubmitDTO){
        return userQuestionService.submit(userQuestionSubmitDTO);
    }

    /**
     * 用户提交代码rabbitmq
     */
    @PostMapping("/rabbit/submit")
    public Result<Void> rabbitmqSubmit(@RequestBody UserQuestionSubmitDTO userQuestionSubmitDTO){
        return toResult(userQuestionService.rabbitmqSubmit(userQuestionSubmitDTO));
    }


    /**
     * 获取答题结果
     */
    @GetMapping("/exe/result")
    public Result<UserQuestionResultVO> exeResult(Long examId,Long questionId,String currentTime){
       return Result.ok(userQuestionService.exeResult(examId,questionId,currentTime));
    }
}
